package com.xbang.attendance.web.action.purchase.scope;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.companygps.scope;
import com.xbang.attendance.service.PurchaseOrderService;
import com.xbang.core.page.Page;
import com.xbang.core.struts.support.SearchActionSupport;
import com.xbang.core.page.Result;

public class Index extends SearchActionSupport{
	
	@Autowired
	private PurchaseOrderService purchaseOrderService;

	private List<scope> scopes;
    
	@Action("/purchase/scope/list")
	public String execute() throws Exception {

		String hqlSentence = "FROM scope scope WHERE 1 = 1 ";

		if (searchComponent.getOrderParameters().isEmpty()) {
		//	searchComponent.addSearchElement("orderBy.scope。id", "DESC");
		}

	if (page != null) {
			if (currPageId.intValue() != -1 && currPageId.intValue() > 0) {
				page.setCurrentPage(currPageId);
			}
		}
	
	
		Result result = purchaseOrderService.searchByPage(hqlSentence, searchComponent, page);
		scopes = result.getItems();
		page = result.getPage();

		return "index";
	}

	public PurchaseOrderService getPurchaseOrderService() {
		return purchaseOrderService;
	}

	public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
		this.purchaseOrderService = purchaseOrderService;
	}

	public List<scope> getScopes() {
		return scopes;
	}

	public void setScopes(List<scope> scopes) {
		this.scopes = scopes;
	}

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub
		
	}
}
